package com.sk.rpcAssist.domain;

import com.sk.rpcAssist.io.protocol.RpcRequest;
import lombok.Data;

import java.util.Arrays;
import java.util.Objects;

/**
 * description：
 *
 * @author 孙文斌
 * @Date: 2021/2/9 15:30
 */
@Data
public class ProvideInfoKey {
    String className;
    String methodName;
    Class<?>[] parameterTypes;

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        ProvideInfoKey that = (ProvideInfoKey) object;
        StringBuilder sb = new StringBuilder();
        for (Class<?> parameterType : parameterTypes) {
            sb.append(parameterType.getName());
        }
        String s = sb.toString();
        StringBuilder sb2 = new StringBuilder();
        for (Class<?> parameterType : that.parameterTypes) {
            sb2.append(parameterType.getName());
        }
        String s1 = sb2.toString();
        return Objects.equals(className, that.className) &&
                Objects.equals(methodName, that.methodName) &&
                Objects.equals(s, s1);
    }

    @Override
    public int hashCode() {
        StringBuilder sb = new StringBuilder();
        for (Class<?> parameterType : parameterTypes) {
            sb.append(parameterType.getName());
        }
        return Objects.hash(className, methodName,sb.toString());
    }
}
